package wms.api.core.bean;

import wms.api.core.utils.Utils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.Date;

/**
 * Created by fisher4u on 2017/11/24.
 */
@JsonIgnoreProperties(value = {"rows", "sortBy", "delFlag", "start", "openPage", "pageNum", "pageSize"})
public abstract class BaseEntity {
    private String id;
    //分页开始
    private Integer openPage = 1;//是否分页，0.不分页 1.分页，默认分页
    private Integer start = 0;
    private Integer rows = 10;
    private Integer pageNum;
    private Integer pageSize;

    private void calculatePage() {
        if (openPage != 0 && start != null && rows != null) {
            this.pageNum = this.start / this.rows + 1;
            this.pageSize = this.rows;
        }
    }

    public void setStart(Integer start) {
        this.start = start;
        calculatePage();
    }

    public void setStart(Integer start, Integer rows) {
        this.start = start;
        this.rows = rows;
        calculatePage();
    }

    public void setRows(Integer rows) {
        this.rows = rows;
        calculatePage();
    }

    public Integer getOpenPage() {
        return openPage;
    }

    public void setOpenPage(Integer openPage) {
        this.openPage = openPage;
    }

    public Integer getRows() {
        return rows;
    }


    public Integer getPageNum() {
        if (openPage == 1) {
            return pageNum;
        } else {
            return null;
        }
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        if (openPage == 1) {
            return pageSize;
        } else {
            return null;
        }
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

}
